package com.alks.common.config;

import io.minio.MinioClient;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author:xxxxx
 * @create: 2023-08-16 09:07
 * @Description: minio配置
 */
@Configuration
@Getter
@Setter
@NoArgsConstructor
public class MinIoConfig {

    /**
     * Minio 服务地址
     */
    @Value("${minio.endpoint}")
    private String endpoint;

    /**
     * Minio 服务端口号
     */
    @Value("${minio.point}")
    private Integer point;

    /**
     * Minio ACCESS_KEY
     */
    @Value("${minio.accessKey}")
    private String accessKey;

    /**
     * Minio SECRET_KEY
     */
    @Value("${minio.secretKey}")
    private String secretKey;

    /**
     * Minio 是否为https 请求，true 地址为http,false地址为http
     */
    @Value("${minio.secure}")
    private boolean secure;

    @Bean
    public MinioClient minioClient(){
        return MinioClient.builder()
                .endpoint(endpoint, point, secure)
                .credentials(accessKey, secretKey)
                .build();
    }
}
